/**
 * @description: 用户信息获取
 * @version: 0.0.1
 * @author: z..
 * @Date: 2023-06-12 18:16:39
 */

import { Inject, Controller, Get, Query, Post, Body } from '@midwayjs/core';
import { UserService } from '../service/user.service';
import { DeptIdDTO } from '../dto/user';
import { Context } from '@midwayjs/koa';

@Controller('/api/v1/user')
export class Users {
  @Inject()
  ctx: Context;
  @Inject()
  UserService: UserService;

  /**
   * @summary 获取用户更多信息
   * @description 获取用户更多信息
   * @router post /api/v1/user/getUserDetails
   * @request body access_token  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getUserDetails')
  async getUserDetails(): Promise<any> {
    return await this.UserService.getUserDetails();
  }

  /**
   * @summary 获取部门列表
   * @description 获取部门列表
   * @router post /api/v1/user/getDeptLists
   * @request body deptId  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getDeptLists')
  async getDeptLists(@Body() options: DeptIdDTO): Promise<any> {
    return await this.UserService.getDeptLists(options.deptId);
  }

  /**
   * @summary 获取部门用户基础信息
   * @description 获取部门用户基础信息
   * @router post /api/v1/user/getDeptUserLists
   * @request body deptId  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getDeptUserLists')
  async getDeptUserLists(@Body() options: DeptIdDTO): Promise<any> {
    return await this.UserService.getDeptUserLists(options.deptId);
  }

  /**
  * @summary 获取用户列表
  * @description 获取用户列表
  * @router get /api/v1/user/getUserLists
  * @request body deptId  *body
  * @response 200 baseResponse 返回结果
  */
  @Post('/getUserLists')
  async getUserLists(@Query('searchKey') searchKey: any): Promise<any> {
    return await this.UserService.getUserLists(searchKey || "");
  }

  /**
   * 校验token是否失效
   */
  @Get('/checkUserToken')
  async checkUserToken(): Promise<any> {
    return true;
  }
}
